package kaiin;

import kaiin.KaiinBeans;

import java.io.IOException;

import java.net.URI;
import java.net.URISyntaxException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LogOut extends HttpServlet{

	public void doGet(HttpServletRequest req, HttpServletResponse res)
	throws IOException, ServletException{
		this.doPost(req, res);
	}

	public void doPost(HttpServletRequest req, HttpServletResponse res)
	throws IOException, ServletException{

		req.setCharacterEncoding("utf-8");

		HttpSession session = req.getSession(true);
		KaiinBeans kbean = (KaiinBeans)session.getAttribute("kaiin");

		kbean.allRemove();

		String message = "ログアウトしました！";
		String title = "ログアウト完了";

		req.setAttribute("title", title);
		req.setAttribute("message", message);

		RequestDispatcher dp = req.getRequestDispatcher("/src/jsp/thanks.jsp");
		dp.forward(req, res);

	}

}
